package controller

import (
    "fmt"
    "gin-demo/model/test"
    "github.com/gin-gonic/gin"
    "time"
)

var TestController testController

type testController struct{}

func (*testController) Hello(c *gin.Context) {
    var h test.Hello
    err := c.BindJSON(&h)
    if err != nil {
        panic(err)
    }
    fmt.Println("username:", h.Username)
    fmt.Println("password:", h.Password)
}

func (*testController) User(c *gin.Context) {
    Response.AddData("name", "itchin")
    Response.AddData("age", 28)
    Response.Output(c)
}

func (*testController) Error(c *gin.Context) {
    Response.Error(c, "this is error msg...", 60001)
}

func (*testController) A(c *gin.Context) {
    time.Sleep(30 * time.Second)
    Response.AddData("a", "a")
    Response.Output(c)
}

func (*testController) B(c *gin.Context) {
    Response.AddData("b", "b")
    Response.Output(c)
}
